home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 2 / MacMania 2.toast / Demo's / Tools&Utilities / System Utilities / ShutDowner 1.0.1 / ShutDowner.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-26  |  853 b   |  52 lines  |  [TEXT/NISI]

  1. #include <asm.h>
  2. #include <Resources.h>
  3. #include <ShutDown.h>
  4. #include <Events.h>
  5.  
  6. extern void SHOWINIT();
  7. #define IconID 128
  8. #define BadIconID 129
  9.  
  10. /*
  11.     shift - 0x38
  12.     control - 0x3B
  13.     esc - 0x35
  14.     end - 0x77
  15. */
  16.  
  17. void
  18. main(void)
  19. {
  20.     long key[4];
  21.     unsigned char *theKeys;
  22.     Handle KeyH;
  23.     
  24.     KeyH = GetResource('SKey', 128);
  25.     if (KeyH == NULL || *KeyH == NULL)
  26.     {
  27.         asm
  28.         {
  29.                 move.w    #BadIconID,-(sp)            ; load ICN# ID
  30.                 move.w    #-1,-(sp)                ; use default moveX
  31.                 bsr        SHOWINIT                ; draw the icon
  32.         }
  33.         return;
  34.     }
  35.     
  36.     GetKeys(key);
  37.     
  38.     theKeys = (unsigned char *)(key);
  39.         
  40.     if ((theKeys[(*((unsigned short*)*KeyH)) >> 3] >> ((*((unsigned short*)*KeyH)) & 7)) & 1)
  41.         ShutDwnPower();
  42.  
  43.     ReleaseResource(KeyH);
  44.  
  45.     asm    /* show init */
  46.     {
  47.                 move.w    #IconID,-(sp)            ; load ICN# ID
  48.                 move.w    #-1,-(sp)                ; use default moveX
  49.                 bsr        SHOWINIT                ; draw the icon
  50.     }
  51.  
  52. }